﻿using MongoDB.Bson;
using System;
using System.Linq;

namespace MongoCamp.Linq
{
    public class MongoQuery : MongoQueryBase<BsonDocument>, IQueryable<BsonDocument>
    {
        private MongoQueryProvider _queryProvider;


        public MongoQuery(string collectionName, MongoServerPack mongoServer)
            : base(collectionName, mongoServer)
        {
        }

        public MongoQuery(string collectionName)
            : base(collectionName)
        {
        }
    }


    public class MongoQuery<TEntityClass> : MongoQueryBase<TEntityClass>, IQueryable<TEntityClass>
        where TEntityClass : class, new()
    {

        public MongoQuery(string collectionName, MongoServerPack mongoServer)
            : base(collectionName, mongoServer)
        { }

        public MongoQuery(string collectionName)
            : base(collectionName)
        { }

        public MongoQuery()
            : base(typeof(TEntityClass).Name)
        {
            Initial(Activator.CreateInstance<TEntityClass>() as IEntityCollection);
        }

        private void Initial(IEntityCollection entity)
        {
            if (entity == null)
                return;

            CollectionName = entity.GetCollectionName();
            MongoServer = entity.GetMongoServer();
        }


    }
}
